import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, sim_items, main, dungeon
from util import *

class Scroll(sim_items.Scroll):
    def __init__(self):
        sim_items.Scroll.__init__(self, "night", "?", 
                ('light', 'far', 'less'),
                idDescription="Reading from this accursed scrolls brings down "\
                    "a heavy curtain of absolute darkness. It is whispered "\
                    "that this scroll is favored by unspeakable cults to "\
                    "commit nocturnal sacrifices whenever they please.")

    def read(self, reader):
        self.map = main.mapFrame.getMap()
        self.originalIntensity = main.originalAmbientIntensity[self.map]

        self.map.setAmbientLight((255,255,255), -0.4)
        self.map.update()

        main.schedule.add(sim.Event('expire effect', main.schedule.time + 2*60000,
            (self,), dests=[self]))
        reader.identify(self)
        main.transient('This darkness is especially oppressive and '\
            'overwhelming.', reader.parentTile)

    def listen(self, event):
        sim_items.Scroll.listen(self, event)

        if event.id == 'expire effect' and event.args[0] is self:
            self.map.setAmbientLight((255,255,255), self.originalIntensity)
            self.map.update()


#========================================
thingClass = Scroll



